﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LotteryVote.Entity;
using LotteryVote.Logic.Exceptions;

namespace LotteryVote.Logic.Web
{
    /// <summary>
    /// 仅会员可用
    /// </summary>
    public class MemberPage : BasePage
    {
        protected virtual SystemRole IdentityRole
        {
            get
            {
                return SystemRole.Guest;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            CheckRole();
            base.OnInit(e);
        }

        protected virtual void CheckRole()
        {
            Execute(() =>
           {
               if (!IsLogin)
                   Response.Redirect("Login.aspx?ReturnUrl=" + Request.RawUrl);
               if (CurrentUser.Role != IdentityRole)
                   throw new NoPermissionException("没有访问权限!");
           });
        }
    }
}
